package com.gxa.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.pojo.Article;
import com.gxa.pojo.Comments;
import com.gxa.dao.CommentsMapper;
import com.gxa.pojo.ContentCommentManagement;
import com.gxa.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentsServiceImpl implements CommentsService {

    @Autowired
    private CommentsMapper commentsMapper;


    @Override
    public List<ContentCommentManagement> showCommentBypage(int pageNum, int pageSize) {

        PageHelper.startPage(pageNum,pageSize);

        List<ContentCommentManagement> contentCommentManagements = commentsMapper.selectCommentBypage();

        return contentCommentManagements;
    }

    public int getCount() {
        List<ContentCommentManagement> contentCommentManagements = commentsMapper.selectCommentBypage();

        PageInfo<ContentCommentManagement> pageInfo=new PageInfo<>(contentCommentManagements);

        int total =(int)pageInfo.getTotal();

        return total;
    }
}
